Skip to content

Conversation

@urmauur
Copy link
Member

@urmauur urmauur commented Jul 28, 2025

Describe Your Changes

This pull request introduces functionality to remember and initialize the last-used assistant in the application, enhancing the user experience by persisting state across sessions. Key changes include updates to local storage management, the assistant state management logic, and the integration of this feature into the application lifecycle.

Enhancements to Assistant State Management:

  • Added new methods getLastUsedAssistant, setLastUsedAssistant, and initializeWithLastUsed to manage the last-used assistant in the useAssistant hook. These methods interact with local storage to persist and retrieve the assistant state. [1] [2]
  • Modified the deleteAssistant function to reset to the default assistant and update local storage if the current assistant is deleted.
  • Updated the setCurrentAssistant function to optionally save the assistant to local storage.

Local Storage Integration:

  • Added a new key, lastUsedAssistant, to the localStorageKey constants for storing the ID of the last-used assistant.

Application Lifecycle Updates:

  • Integrated the initializeWithLastUsed method into the DataProvider component to automatically set the last-used assistant on application startup if available. [1] [2]

Minor Adjustments:

  • Passed the currentAssistant to the useChat hook to ensure the correct assistant context is used during chat operations.
  • Fixed minor formatting issues in the defaultAssistant object, replacing double quotes with single quotes for consistency.

Fixes Issues

Screen.Recording.2025-07-28.at.21.35.18.mp4

Self Checklist

  • Added relevant comments, esp in complex areas
  • Updated docs (for bug fixes / features)
  • Created issues for follow-up changes or refactoring needed

Important

Adds functionality to remember and initialize the last-used assistant, updating state management, local storage, and application lifecycle.

  • Assistant State Management:
    • Added getLastUsedAssistant, setLastUsedAssistant, and initializeWithLastUsed in useAssistant to manage last-used assistant state.
    • Modified deleteAssistant to reset to default assistant if current is deleted.
    • Updated setCurrentAssistant to optionally save to local storage.
  • Local Storage:
    • Added lastUsedAssistant key in localStorageKey for storing last-used assistant ID.
  • Application Lifecycle:
    • Integrated initializeWithLastUsed in DataProvider to set last-used assistant on startup.
  • Miscellaneous:
    • Passed currentAssistant to useChat for correct context.
    • Fixed formatting in defaultAssistant object.

This description was created by Ellipsis for cb6b09b. You can customize this summary. It will automatically update as commits are pushed.

@urmauur urmauur added this to the v0.6.6 milestone Jul 28, 2025
@urmauur urmauur self-assigned this Jul 28, 2025
@urmauur urmauur added this to Jan Jul 28, 2025
@urmauur urmauur moved this to Needs Review in Jan Jul 28, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 850fe73 in 1 minute and 12 seconds. Click for details.
  • Reviewed 152 lines of code in 4 files
  • Skipped 0 files when reviewing.
  • Skipped posting 6 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/constants/localStorage.ts:21
  • Draft comment:
    Good addition of 'lastUsedAssistant' key for localStorage; centralizing keys is best practice.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. web-app/src/hooks/useAssistant.ts:94
  • Draft comment:
    Nice extension of setCurrentAssistant with the optional saveToStorage flag; consider adding a brief code comment documenting this parameter.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. web-app/src/hooks/useAssistant.ts:83
  • Draft comment:
    Deleting the current assistant properly resets to default and updates localStorage; ensure unit tests cover this fallback behavior.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. web-app/src/hooks/useAssistant.ts:109
  • Draft comment:
    initializeWithLastUsed robustly selects the persisted assistant; consider logging a debug message when the stored assistant isn’t found for easier troubleshooting.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. web-app/src/hooks/useChat.ts:402
  • Draft comment:
    Passing currentAssistant into the final content object ensures proper assistant context; verify that currentAssistant is always up-to-date.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
6. web-app/src/providers/DataProvider.tsx:40
  • Draft comment:
    Calling initializeWithLastUsed after setting assistants ensures the persisted selection is applied, effectively resolving #5935.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_4SCMeEJt6uTmoNud

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 28, 2025

@urmauur urmauur requested review from louis-jan and removed request for louis-jan July 28, 2025 15:03
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed 0d004fe in 1 minute and 1 seconds. Click for details.
  • Reviewed 43 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/hooks/useAssistant.ts:43
  • Draft comment:
    Good change: The default assistant description now uses a typographically consistent apostrophe (“user’s” vs "user's"). Ensure this change in text does not affect any downstream dependencies expecting an exact match.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. web-app/src/hooks/useAssistant.ts:46
  • Draft comment:
    Formatting consistency: The instructions string now uses curly apostrophes and improved formatting. This is purely cosmetic and improves readability.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
3. web-app/src/hooks/useAssistant.ts:89
  • Draft comment:
    In deleteAssistant, resetting currentAssistant and updating localStorage upon deletion of the current assistant correctly addresses the bug reported in #5935.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. web-app/src/hooks/useAssistant.ts:111
  • Draft comment:
    The initializeWithLastUsed method properly checks localStorage and falls back to the default assistant if the stored assistant isn't found. This should resolve the issue where the selected assistant resets.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_Gw5TVgzv3D5uEHWX

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed 2add751 in 1 minute and 38 seconds. Click for details.
  • Reviewed 115 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/hooks/useChat.ts:75
  • Draft comment:
    You compute a selectedAssistant fallback here, but later in the sendMessage callback you still use currentAssistant. For consistency (and to ensure the persisted assistant is used everywhere), consider using selectedAssistant throughout.
  • Reason this comment was not posted:
    Comment was on unchanged code.
2. web-app/src/hooks/useChat.ts:245
  • Draft comment:
    When creating the CompletionMessagesBuilder and later in the sendCompletion call, the code still uses currentAssistant (e.g. currentAssistant?.instructions and currentAssistant.parameters). To keep behavior consistent with getCurrentThread (which uses selectedAssistant), switch these references to selectedAssistant.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_T3vgfgABwjiq5LzY

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed 0ffa9eb in 1 minute and 55 seconds. Click for details.
  • Reviewed 56 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/hooks/useAppState.ts:41
  • Draft comment:
    Ensure currentAssistant is defined before accessing its id; also check that assistants is non-empty to prevent potential runtime errors.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% While the comment identifies potential runtime issues, I need to consider: 1) Is this actually a problem? 2) The code has a fallback to assistants[0] 3) This is state management code using Zustand, which typically initializes state 4) Without seeing useAssistant's implementation, I can't be certain these checks are necessary 5) The suggestion might make the code more defensive but could also make it less readable I don't have visibility into useAssistant's implementation - these values could be guaranteed to exist. The current code might be intentionally simple because null states are handled elsewhere. Without seeing the full context of how assistants and currentAssistant are managed, suggesting additional null checks could be overly defensive and unnecessary. Delete this comment. Without strong evidence that these null states are possible or problematic, adding defensive coding would just add complexity.
2. web-app/src/hooks/useAppState.ts:41
  • Draft comment:
    Consider refactoring the repeated logic for selecting the assistant into a shared helper to reduce duplication.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. web-app/src/hooks/useMessages.ts:34
  • Draft comment:
    Ensure currentAssistant is defined and that assistants is non-empty before accessing properties to avoid potential runtime errors.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The code already handles the case where currentAssistant.id doesn't match any assistant by falling back to assistants[0]. TypeScript would catch undefined access. The comment is asking for verification rather than pointing out a specific issue. This seems like the kind of defensive programming that TypeScript already handles. I might be assuming too much about TypeScript's type checking. There could be edge cases where assistants is an empty array. Even if assistants is empty, this would be a configuration/initialization issue that should be caught in testing, not something to handle defensively in this hook. Delete the comment because it asks for verification rather than pointing out a specific issue, and the code already has reasonable fallbacks in place.
4. web-app/src/hooks/useMessages.ts:45
  • Draft comment:
    Consider adding error handling for the createMessage promise to handle potential rejections.
  • Reason this comment was not posted:
    Comment was on unchanged code.
5. web-app/src/hooks/useMessages.ts:34
  • Draft comment:
    Similar to useAppState.ts, consider abstracting the assistant selection logic to avoid code duplication.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_IHV9KArK9fnbFOTO

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed cb6b09b in 46 seconds. Click for details.
  • Reviewed 14 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. web-app/src/hooks/__tests__/useAppState.test.ts:15
  • Draft comment:
    Good update – the mock now includes the 'assistants' array to reflect the new assistant persistence functionality. Ensure that this structure matches the expected schema in useAssistant.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None

Workflow ID: wflow_rJA4lLZO4Qgj5bAX

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@Minh141120 Minh141120 self-requested a review July 29, 2025 02:21
@urmauur urmauur requested a review from louis-jan July 29, 2025 02:32
@Minh141120
Copy link
Member

LGTM!
I also did some test to create new assistant and delete default assistant, relaunch and reload also working well!

image image image

@urmauur urmauur merged commit 63cb4fb into release/v0.6.6 Jul 29, 2025
18 of 20 checks passed
@urmauur urmauur deleted the fix/assistants branch July 29, 2025 02:50
@github-project-automation github-project-automation bot moved this from Needs Review to QA in Jan Jul 29, 2025
@github-actions github-actions bot modified the milestones: v0.6.6, v0.6.7 Jul 29, 2025
@urmauur urmauur removed this from the v0.6.7 milestone Jul 30, 2025
@urmauur urmauur added this to the v0.6.6 milestone Jul 30, 2025
@urmauur urmauur moved this from QA to Done in Jan Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

bug: App resets selected assistant in starter screen bug: Custom assistant not always loaded, default Jan is used instead

4 participants